#ifndef __SYSCALLS_H__
#define __SYSCALLS_H__

#include "util/Logger.h"

extern Logger* syscallLog;

typedef enum SysCallHookRet {
    SC_HANDLED,
    SC_STALL,
    SC_NOTHANDLED
} SysCallHookRet;

class CPU;

typedef SysCallHookRet (*SysCallPreHookPtr)(CPU*, Reg_s, Reg*, Reg*);
typedef SysCallHookRet (*SysCallPostHookPtr)(CPU*, Reg_s, Reg*);

void register_pre_syscall_hook (SysCallPreHookPtr f);
void register_post_syscall_hook (SysCallPostHookPtr f);

SysCallHookRet do_pre_syscall_hook (CPU* cpu,
                                    Reg_s sc_id,
                                    Reg* args,
                                    Reg* sc_return);
void do_post_syscall_hook (CPU* cpu, Reg_s sc_id, Reg* args);

SysCallHookRet std_pre_syscall_hook (CPU* cpu,
                                     Reg_s sc_id,
                                     Reg* args,
                                     Reg* sc_return);
SysCallHookRet std_post_syscall_hook (CPU* cpu, Reg_s sc_id, Reg* args);

void init_syscalls ();

SysCallHookRet checkSyscallInParallelRegion (CPU* cpu,
                                             Reg_s sc_id,
                                             Reg* args,
                                             Reg* sc_return);

#endif
